<?php
namespace cms\modules\frontend\controllers;

use Yii;
use yii\helpers\Html;
use yii\db\Expression;
use cms\controllers\BasicController;
use app\models\Nav;
use app\models\NavSearch;
use common\component\tool\Tool;


class NavController extends BasicController
{

    /*导航菜单*/
    public function actionNav()
    {
        $this->get['app_id'] = $this->app_id;
        $this->get['display'] = 2;//只取显示的
        // P($this->get);
        $search = (new NavSearch())->search($this->get);
        if($search === false){//验证搜索参数不通过
            $count = 0;
            $navList = array();
        }else{
            if(isset($this->get['type']) and $this->get['type'] == 'ele'){
                $flag = 'ele';
            }else{
                $flag = '';
            }
            if(isset( $this->get['parentid'] )){
                $parentid = $this->get['parentid'];
            }else{
                $parentid = 0;
            }
            // P($search);
            $navList = Nav::getTreeList($search, $this->app_id, $flag, $parentid);
        }
        // P($navList);
        return Tool::showRes([0, '获取成功'], $navList);
    }


}
